package base2dev.web.pages.musics.crud;

import musics.model.Artist;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.spring.injection.annot.SpringBean;

import base2dev.core.model.Bag;
import base2dev.web.common.MasterPage;

public class ArtistForm  extends MasterPage {


	@SpringBean(name = "artists")
	private Bag<Artist> artists;
	private Artist entity;

	
	public ArtistForm() {
		this(new Artist().setId(0L));
	}
	
	public ArtistForm(Artist a) {
		
		super("title");

		if (a.getId()==0)
			setEntity(a);
		else
			setEntity(getArtists().get(a.getId()));
		
		add(new Label("artist.name", getEntity().getName()));
		add(new Label("artist.nick", getEntity().getNickName()));
		
		add(new Label("txt.artist.name", getEntity().getName()));
		add(new Label("txt.artist.nick", getEntity().getNickName()));
		add(new Label("txt.artist.history", getEntity().getHistory()));
		add(new Label("txt.artist.points", "" + getEntity().getPoints()));
	}

	@Override
	public void setControls() {
		//call beforeset entity
		
	}

	public void setEntity(Artist entity) {
		this.entity = entity;
	}

	public Artist getEntity() {
		return entity;
	}

	public void setArtists(Bag<Artist> artists) {
		this.artists = artists;
	}

	public Bag<Artist> getArtists() {
		return artists;
	}

}
